﻿Imports System.IO
Imports System.Net
Imports Newtonsoft.Json

Public Class KomponenLibrary
    Private url As String
    Private searchBy As String
    Dim index As Integer = 0
    Dim tampungbuku As String
    Dim client As WebClient

    Property UrlRest As String
        Get
            Return url
        End Get
        Set(ByVal value As String)
            url = value
        End Set
    End Property

    Property Search As String
        Get
            Return searchBy
        End Get
        Set(ByVal value As String)
            url = value
        End Set
    End Property

    Public Class Buku
        Private id As ArrayList
        Private judul As String
        Private author As ArrayList
        Private subjek As ArrayList
        Private publish As ArrayList
        Private sampul As String
        Private no As String

        Property isbn As ArrayList
            Get
                Return id
            End Get
            Set(ByVal value As ArrayList)
                id = value
            End Set
        End Property

        Property title As String
            Get
                Return judul

            End Get
            Set(ByVal value As String)
                judul = value

            End Set
        End Property

        Property author_name As ArrayList
            Get
                Return author

            End Get
            Set(ByVal value As ArrayList)
                author = value
            End Set
        End Property

        Property subject As ArrayList
            Get
                Return subjek

            End Get
            Set(ByVal value As ArrayList)
                subjek = value

            End Set
        End Property

        Property publisher As ArrayList
            Get
                Return publish

            End Get
            Set(ByVal value As ArrayList)
                publish = value

            End Set
        End Property

        Property cover_i As String
            Get
                Return sampul
            End Get
            Set(ByVal value As String)
                sampul = value
            End Set
        End Property

        Property idx As String
            Get
                Return no
            End Get
            Set(ByVal value As String)
                no = value
            End Set
        End Property
    End Class

    Public Class Dokumentasi
        Private document As ArrayList
        Private num As String
        Private sampul As String

        Property docs As ArrayList
            Get
                Return document
            End Get
            Set(ByVal value As ArrayList)
                document = value
            End Set
        End Property

        Property numFound As String
            Get
                Return num
            End Get
            Set(ByVal value As String)
                num = value
            End Set
        End Property

        Property cover_i As String
            Get
                Return sampul
            End Get
            Set(ByVal value As String)
                sampul = value
            End Set
        End Property

    End Class

    Dim buku1 As Buku
    Dim buku2 As Buku
    Dim buku3 As Buku
    Dim buku4 As Buku
    Dim buku5 As Buku
    Dim buku6 As Buku
    Dim buku7 As Buku
    Dim buku8 As Buku
    Dim buku9 As Buku
    Dim buku10 As Buku
    Dim buku11 As Buku
    Dim buku12 As Buku
    Dim tampung As Dokumentasi


    Public Sub searchBook(ByVal metode As String, ByVal cari As String)


        ' Create a request for the URL. 		
        Dim request As WebRequest = WebRequest.Create("http://openlibrary.org/search.json?" + metode + "=" + cari)

        'Dim request As WebRequest = WebRequest.Create("http://lecturer.ukdw.ac.id/yuan/labs/quotes2/random")

        ' If required by the server, set the credentials.
        request.Credentials = CredentialCache.DefaultCredentials
        ' Get the response.
        Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
        ' Display the status.
        Console.WriteLine(response.StatusDescription)
        ' Get the stream containing content returned by the server.
        Dim dataStream As Stream = response.GetResponseStream()
        ' Open the stream using a StreamReader for easy access.
        Dim reader As New StreamReader(dataStream)
        ' Read the content.
        Dim responseFromServer As String = reader.ReadToEnd()
        ' Display the content.
        'Console.WriteLine(responseFromServer)

       
        tampung = JsonConvert.DeserializeObject(Of Dokumentasi)(responseFromServer)
        'Dim tampung As Buku = JsonConvert.DeserializeObject(Of Buku)(responseFromServer)
        Dim jumlah As Integer = tampung.docs.Count
        Label2.Text = "Jumlah : " + jumlah.ToString
        Dim client As New WebClient
        Dim urlImage As String = "http://covers.openlibrary.org/b/id/"

        index = 0

        Dim testing As String = tampung.docs(index).ToString()
        buku1 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku1.idx = index
        

        'buku ke 1

        Try
            client.DownloadFile(urlImage + buku1.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku1.idx + ".jpg")
            client.Dispose()
            PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku1.idx + ".jpg")
        Catch ex As Exception

        End Try
        


        'buku2
        index += 1
        testing = tampung.docs(index).ToString()
        buku2 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku2.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku2.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku2.idx + ".jpg")
            client.Dispose()
            PictureBox2.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku2.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku3
        index += 1
        testing = tampung.docs(index).ToString()
        buku3 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku3.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku3.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku3.idx + ".jpg")
            client.Dispose()
            PictureBox3.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku3.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku4
        index += 1
        testing = tampung.docs(index).ToString()
        buku4 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku4.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku4.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku4.idx + ".jpg")
            client.Dispose()
            PictureBox4.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku4.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku5
        index += 1
        testing = tampung.docs(index).ToString()
        buku5 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku5.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku4.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku5.idx + ".jpg")
            client.Dispose()
            PictureBox5.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku5.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku6
        index += 1
        testing = tampung.docs(index).ToString()
        buku6 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku6.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku6.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku6.idx + ".jpg")
            client.Dispose()
            PictureBox6.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku6.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku7
        index += 1
        testing = tampung.docs(index).ToString()
        buku7 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku7.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku7.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku7.idx + ".jpg")
            client.Dispose()
            PictureBox7.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku7.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku8
        index += 1
        testing = tampung.docs(index).ToString()
        buku8 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku8.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku8.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku8.idx + ".jpg")
            client.Dispose()
            PictureBox8.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku8.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku9
        index += 1
        testing = tampung.docs(index).ToString()
        buku9 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku9.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku9.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku9.idx + ".jpg")
            client.Dispose()
            PictureBox9.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku9.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku10
        index += 1
        testing = tampung.docs(index).ToString()
        buku10 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku10.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku10.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku10.idx + ".jpg")
            client.Dispose()
            PictureBox10.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku10.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku11
        index += 1
        testing = tampung.docs(index).ToString()
        buku11 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku11.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku11.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku11.idx + ".jpg")
            client.Dispose()
            PictureBox11.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku11.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku12
        index += 1
        testing = tampung.docs(index).ToString()
        buku12 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku12.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku12.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku12.idx + ".jpg")
            client.Dispose()
            PictureBox12.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku12.idx + ".jpg")
        Catch ex As Exception
        End Try


        ' Cleanup the streams and the response.
        reader.Close()
        dataStream.Close()
        response.Close()



    End Sub


    'mouse hover
    Private Sub PictureBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseHover
        PictureBox1.Size = New Size(70, 90)
        PictureBox1.Location = New Point(28, 22)
    End Sub

    Private Sub PictureBox2_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseHover
        PictureBox2.Size = New Size(70, 90)
        PictureBox2.Location = New Point(137, 22)
    End Sub

    Private Sub PictureBox3_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.MouseHover
        PictureBox3.Size = New Size(70, 90)
        PictureBox3.Location = New Point(240, 22)
    End Sub

    Private Sub PictureBox4_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox4.MouseHover
        PictureBox4.Size = New Size(70, 90)
        PictureBox4.Location = New Point(28, 130)
    End Sub

    Private Sub PictureBox5_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox5.MouseHover
        PictureBox5.Size = New Size(70, 90)
        PictureBox5.Location = New Point(137, 130)
    End Sub

    Private Sub PictureBox6_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox6.MouseHover
        PictureBox6.Size = New Size(70, 90)
        PictureBox6.Location = New Point(240, 130)
    End Sub

    Private Sub PictureBox7_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox7.MouseHover
        PictureBox7.Size = New Size(70, 90)
        PictureBox7.Location = New Point(28, 238)
    End Sub

    Private Sub PictureBox8_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox8.MouseHover
        PictureBox8.Size = New Size(70, 90)
        PictureBox8.Location = New Point(137, 238)
    End Sub

    Private Sub PictureBox9_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox9.MouseHover
        PictureBox9.Size = New Size(70, 90)
        PictureBox9.Location = New Point(240, 238)
    End Sub

    Private Sub PictureBox10_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox10.MouseHover
        PictureBox10.Size = New Size(70, 90)
        PictureBox10.Location = New Point(28, 343)
    End Sub

    Private Sub PictureBox11_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox11.MouseHover
        PictureBox11.Size = New Size(70, 90)
        PictureBox11.Location = New Point(137, 343)
    End Sub

    Private Sub PictureBox12_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox12.MouseHover
        PictureBox12.Size = New Size(70, 90)
        PictureBox12.Location = New Point(240, 343)
    End Sub

    'mouse leave
    Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
        PictureBox1.Size = New Size(60, 80)
        PictureBox1.Location = New Point(33, 27)
    End Sub


    Private Sub PictureBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseLeave
        PictureBox2.Size = New Size(60, 80)
        PictureBox2.Location = New Point(142, 27)
    End Sub



    Private Sub PictureBox3_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox3.MouseLeave
        PictureBox3.Size = New Size(60, 80)
        PictureBox3.Location = New Point(245, 27)
    End Sub

    Private Sub PictureBox4_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox4.MouseLeave
        PictureBox4.Size = New Size(60, 80)
        PictureBox4.Location = New Point(33, 135)
    End Sub



    Private Sub PictureBox5_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox5.MouseLeave
        PictureBox5.Size = New Size(60, 80)
        PictureBox5.Location = New Point(142, 135)
    End Sub

    Private Sub PictureBox6_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox6.MouseLeave
        PictureBox6.Size = New Size(60, 80)
        PictureBox6.Location = New Point(245, 135)
    End Sub

    Private Sub PictureBox7_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox7.MouseLeave
        PictureBox7.Size = New Size(60, 80)
        PictureBox7.Location = New Point(33, 243)
    End Sub

    Private Sub PictureBox8_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox8.MouseLeave
        PictureBox8.Size = New Size(60, 80)
        PictureBox8.Location = New Point(142, 243)
    End Sub

    Private Sub PictureBox9_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox9.MouseLeave
        PictureBox9.Size = New Size(60, 80)
        PictureBox9.Location = New Point(245, 243)
    End Sub


    Private Sub PictureBox10_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox10.MouseLeave
        PictureBox10.Size = New Size(60, 80)
        PictureBox10.Location = New Point(33, 348)
    End Sub


    Private Sub PictureBox11_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox11.MouseLeave
        PictureBox11.Size = New Size(60, 80)
        PictureBox11.Location = New Point(142, 348)
    End Sub

    Private Sub PictureBox12_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox12.MouseLeave
        PictureBox12.Size = New Size(60, 80)
        PictureBox12.Location = New Point(245, 348)
    End Sub


    'mouse click picture
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku1.title
            Form1.Label2.Text = buku1.author_name(0).ToString
            Form1.Label3.Text = buku1.isbn(0).ToString
            If buku1.subject IsNot Nothing Then
                Form1.Label4.Text = buku1.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku1.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()
    End Sub

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku2.title
            Form1.Label2.Text = buku2.author_name(0).ToString
            Form1.Label3.Text = buku2.isbn(0).ToString
            If buku2.subject IsNot Nothing Then
                Form1.Label4.Text = buku2.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku2.idx + ".jpg")
        Catch ex As Exception

        End Try

        Form1.ShowDialog()
    End Sub


    Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click

        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku3.title
            Form1.Label2.Text = buku3.author_name(0).ToString
            Form1.Label3.Text = buku3.isbn(0).ToString
            If buku3.subject IsNot Nothing Then
                Form1.Label4.Text = buku3.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku3.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()
    End Sub


    Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click

        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku4.title
            Form1.Label2.Text = buku4.author_name(0).ToString
            Form1.Label3.Text = buku4.isbn(0).ToString
            If buku4.subject IsNot Nothing Then
                Form1.Label4.Text = buku4.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku4.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()
    End Sub


    Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku5.title
            Form1.Label2.Text = buku5.author_name(0).ToString
            Form1.Label3.Text = buku5.isbn(0).ToString
            If buku5.subject IsNot Nothing Then
                Form1.Label4.Text = buku5.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku5.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()
    End Sub


    Private Sub PictureBox6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox6.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku6.title
            Form1.Label2.Text = buku6.author_name(0).ToString
            Form1.Label3.Text = buku6.isbn(0).ToString
            If buku6.subject IsNot Nothing Then
                Form1.Label4.Text = buku6.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku6.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()
    End Sub


    Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku7.title
            Form1.Label2.Text = buku7.author_name(0).ToString
            Form1.Label3.Text = buku7.isbn(0).ToString
            If buku7.subject IsNot Nothing Then
                Form1.Label4.Text = buku7.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku7.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()
    End Sub



    Private Sub PictureBox8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox8.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku8.title
            Form1.Label2.Text = buku8.author_name(0).ToString
            Form1.Label3.Text = buku8.isbn(0).ToString
            If buku8.subject IsNot Nothing Then
                Form1.Label4.Text = buku8.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku8.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()
    End Sub


    Private Sub PictureBox9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox9.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku9.title
            Form1.Label2.Text = buku9.author_name(0).ToString
            Form1.Label3.Text = buku9.isbn(0).ToString
            If buku9.subject IsNot Nothing Then
                Form1.Label4.Text = buku9.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku9.idx + ".jpg")
        Catch ex As Exception

        End Try

        Form1.ShowDialog()
    End Sub



    Private Sub PictureBox10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox10.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku10.title
            Form1.Label2.Text = buku10.author_name(0).ToString
            Form1.Label3.Text = buku10.isbn(0).ToString
            If buku10.subject IsNot Nothing Then
                Form1.Label4.Text = buku10.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku10.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()
    End Sub


    Private Sub PictureBox11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox11.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku11.title
            Form1.Label2.Text = buku11.author_name(0).ToString
            Form1.Label3.Text = buku11.isbn(0).ToString
            If buku11.subject IsNot Nothing Then
                Form1.Label4.Text = buku11.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku11.idx + ".jpg")
        Catch ex As Exception

        End Try

        Form1.ShowDialog()
    End Sub


    Private Sub PictureBox12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox12.Click
        Form1.PictureBox1.Image = Nothing
        Try
            Form1.Label1.Text = buku12.title
            Form1.Label2.Text = buku12.author_name(0).ToString
            Form1.Label3.Text = buku12.isbn(0).ToString
            If buku12.subject IsNot Nothing Then
                Form1.Label4.Text = buku12.subject(0).ToString
            End If
            Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku11.idx + ".jpg")
        Catch ex As Exception

        End Try
        Form1.ShowDialog()


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click



        If index <> 0 Then

            Dim client As New WebClient
            Dim urlImage As String = "http://covers.openlibrary.org/b/id/"

            PictureBox1.Image = Nothing
            PictureBox2.Image = Nothing
            PictureBox3.Image = Nothing
            PictureBox4.Image = Nothing
            PictureBox5.Image = Nothing
            PictureBox6.Image = Nothing
            PictureBox7.Image = Nothing
            PictureBox8.Image = Nothing
            PictureBox9.Image = Nothing
            PictureBox10.Image = Nothing
            PictureBox11.Image = Nothing
            PictureBox12.Image = Nothing

            index += 1

            Dim testing As String = tampung.docs(index).ToString()
            buku1 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku1.idx = Convert.ToString(index)


            'buku ke 1
            Try
                client.DownloadFile(urlImage + buku1.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku1.idx + ".jpg")
                client.Dispose()
                PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku1.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku2
            index += 1
            testing = tampung.docs(index).ToString()
            buku2 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku2.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku2.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku2.idx + ".jpg")
                client.Dispose()
                PictureBox2.Image = System.Drawing.Image.FromFile("E:\tampung cover\" + buku2.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku3
            index += 1
            testing = tampung.docs(index).ToString()
            buku3 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku3.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku3.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku3.idx + ".jpg")
                client.Dispose()
                PictureBox3.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku3.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku4
            index += 1
            testing = tampung.docs(index).ToString()
            buku4 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku4.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku4.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku4.idx + ".jpg")
                client.Dispose()
                PictureBox4.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku4.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku5
            index += 1
            testing = tampung.docs(index).ToString()
            buku5 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku5.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku4.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku5.idx + ".jpg")
                client.Dispose()
                PictureBox5.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku5.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku6
            index += 1
            testing = tampung.docs(index).ToString()
            buku6 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku6.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku6.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku6.idx + ".jpg")
                client.Dispose()
                PictureBox6.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku6.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku7
            index += 1
            testing = tampung.docs(index).ToString()
            buku7 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku7.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku7.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku7.idx + ".jpg")
                client.Dispose()
                PictureBox7.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku7.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku8
            index += 1
            testing = tampung.docs(index).ToString()
            buku8 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku8.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku8.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku8.idx + ".jpg")
                client.Dispose()
                PictureBox8.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku8.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku9
            index += 1
            testing = tampung.docs(index).ToString()
            buku9 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku9.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku9.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku9.idx + ".jpg")
                client.Dispose()
                PictureBox9.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku9.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku10
            index += 1
            testing = tampung.docs(index).ToString()
            buku10 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku10.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku10.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku10.idx + ".jpg")
                client.Dispose()
                PictureBox10.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku10.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku11
            index += 1
            testing = tampung.docs(index).ToString()
            buku11 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku11.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku11.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku11.idx + ".jpg")
                client.Dispose()
                PictureBox11.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku11.idx + ".jpg")
            Catch ex As Exception
            End Try

            'buku12
            index += 1
            testing = tampung.docs(index).ToString()
            buku12 = JsonConvert.DeserializeObject(Of Buku)(testing)
            buku12.idx = Convert.ToString(index)
            Try
                client.DownloadFile(urlImage + buku12.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku12.idx + ".jpg")
                client.Dispose()
                PictureBox12.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku12.idx + ".jpg")
            Catch ex As Exception
            End Try


        End If

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click


        Dim client As New WebClient
        Dim urlImage As String = "http://covers.openlibrary.org/b/id/"

        PictureBox1.Image = Nothing
        PictureBox2.Image = Nothing
        PictureBox3.Image = Nothing
        PictureBox4.Image = Nothing
        PictureBox5.Image = Nothing
        PictureBox6.Image = Nothing
        PictureBox7.Image = Nothing
        PictureBox8.Image = Nothing
        PictureBox9.Image = Nothing
        PictureBox10.Image = Nothing
        PictureBox11.Image = Nothing
        PictureBox12.Image = Nothing

        'buku12
        index -= 12
        Dim testing As String = tampung.docs(index).ToString()
        buku12 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku12.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku12.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku12.idx + ".jpg")
            client.Dispose()
            PictureBox12.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku12.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku11
        index -= 1
        testing = tampung.docs(index).ToString()
        buku11 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku11.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku11.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku11.idx + ".jpg")
            client.Dispose()
            PictureBox11.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku11.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku10
        index -= 1
        testing = tampung.docs(index).ToString()
        buku10 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku10.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku10.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku10.idx + ".jpg")
            client.Dispose()
            PictureBox10.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku10.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku9
        index -= 1
        testing = tampung.docs(index).ToString()
        buku9 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku9.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku9.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku9.idx + ".jpg")
            client.Dispose()
            PictureBox9.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku9.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku8
        index -= 1
        testing = tampung.docs(index).ToString()
        buku8 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku8.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku8.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku8.idx + ".jpg")
            client.Dispose()
            PictureBox8.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku8.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku7
        index -= 1
        testing = tampung.docs(index).ToString()
        buku7 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku7.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku7.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku7.idx + ".jpg")
            client.Dispose()
            PictureBox7.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku7.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku6
        index -= 1
        testing = tampung.docs(index).ToString()
        buku6 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku6.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku6.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku6.idx + ".jpg")
            client.Dispose()
            PictureBox6.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku6.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku5
        index -= 1
        testing = tampung.docs(index).ToString()
        buku5 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku5.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku4.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku5.idx + ".jpg")
            client.Dispose()
            PictureBox5.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku5.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku4
        index -= 1
        testing = tampung.docs(index).ToString()
        buku4 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku4.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku4.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku4.idx + ".jpg")
            client.Dispose()
            PictureBox4.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku4.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku3
        index -= 1
        testing = tampung.docs(index).ToString()
        buku3 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku3.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku3.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku3.idx + ".jpg")
            client.Dispose()
            PictureBox3.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku3.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku2
        index -= 1
        testing = tampung.docs(index).ToString()
        buku2 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku2.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku2.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku2.idx + ".jpg")
            client.Dispose()
            PictureBox2.Image = System.Drawing.Image.FromFile("E:\tampung cover\" + buku2.idx + ".jpg")
        Catch ex As Exception
        End Try

        'buku ke 1
        index -= 1
        testing = tampung.docs(index).ToString()
        buku1 = JsonConvert.DeserializeObject(Of Buku)(testing)
        buku1.idx = Convert.ToString(index)
        Try
            client.DownloadFile(urlImage + buku1.cover_i + "-M.jpg", "E:\tampung cover\buku" + buku1.idx + ".jpg")
            client.Dispose()
            PictureBox1.Image = System.Drawing.Image.FromFile("E:\tampung cover\buku" + buku1.idx + ".jpg")
        Catch ex As Exception
        End Try

        index += 11
        
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If index < 12 Then
            Button3.Visible = False
        Else
            Button3.Visible = True
        End If

        If index = 0 Then
            Button2.Visible = False
        Else
            Button2.Visible = True
        End If

    End Sub

End Class
